package com.ginage.gaugemanager.utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5 {
	public static String parse(String str) {
		if (str != null) {

			try {
				MessageDigest md = MessageDigest.getInstance("MD5");
				StringBuffer buffer = new StringBuffer();
				byte[] digest = md.digest(str.getBytes());
				for (byte b : digest) {
					String s = Integer.toHexString(b & 0xff);
					if (s.length() < 2) {
						s = "0" + s;
					}

					buffer.append(s);
				}
				return buffer.toString();
			} catch (NoSuchAlgorithmException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}
		return null;
	}
}
